/*
* Created on 07.12.2003
*/
package observations;
/**
* <code>Phenomenon</code> Is a particular phenomenon like 'high' or 'obese'.
* It is part of Fowler's pattern 'Observation'. Each phenomenon is a value for
* some phenomenon type.
*
* @author Sascha Hemminger
* @version 2004-09-10
* @see observations.PhenomenonType
*/
public class Phenomenon extends DomainObject {
/**
* Use this to search a phenomenon by name.
*
* @param name
* name of the phenomenon to search
* @return the found phenomenon
*/
public static Phenomenon get(String name) {
return (Phenomenon) Registrar.get("Phenomenon", name);
}
private QuantityRange range;
private PhenomenonType type;
/**
* Default constructor for phenomenon.
*
* @see observations.DomainObject#DomainObject()
*/
public Phenomenon() {
super();
}
/**
* Constructs a new phenomenon object.
*
* @param name
* the name of the phenomenon
* @see observations.DomainObject#DomainObject(String)
*/
public Phenomenon(String name) {
super(name);
}
/**
* Constructs a new phenomenon object with a particular type.
*
* @param name
* the name of the phenomenon
* @param type
* the phenomenon type for the phenomenon
* @see observations.DomainObject#DomainObject(String)
*/
public Phenomenon(String name, PhenomenonType type) {
super(name);
this.type = type;
type.friendPhenomenonAdd(this);
}
/**
* Gives the phenomenon's name.
*
* @return name of phenomenon
* @see observations.DomainObject#getName()
*/
public String getName() {
return name;
}
/**
* Gives the type for the phenomenon.
*
* @return particular type of this phenomenon
*/
public PhenomenonType getPhenomenonType() {
return type;
}
/**
* Tests whether the quantity is included in the phenomenon's range.
*
* @param arg
* quantity to test
* @return true if the quantity is included in the phenomenon's quantity
* range
*/
public boolean includes(Quantity arg) {
return (range == null ? false : range.includes(arg));
}
/**
* Saves the phenomenon.
*
* @return the phenomenon
*/
public Phenomenon persist() {
Registrar.add("Phenomenon", this);
return this;
}
/**
* Sets the range of the phenomenon eg. '80 mm/Hg - 120 mm/Hg'.
*
* @param arg
* the range of the phenomenon
*/
public void setRange(QuantityRange arg) {
range = arg;
}
}
|